<template>
  <div>
    <svg-icon
      :icon-class="isOn ? 'exit-fullscreen' : 'fullscreen'"
      class="fullscreen"
      @click="handleToggle"
    />
  </div>
</template>

<script>
import ScreenFull from "screenfull";
export default {
  name: "ScreenFull",
  data() {
    return {
      isOn: false,
    };
  },
  methods: {
    handleToggle() {
      if (ScreenFull.isEnabled) {
        ScreenFull.toggle();
        this.isOn = !this.isOn;
      } else {
        this.$message.warning("请升级浏览器");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.fullscreen {
  width: 20px;
  height: 20px;
  fill: #fff;
  cursor: pointer;
}
</style>